package com.vdf.sisconsolid.rest.definition;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;

import com.vdf.sisconsolid.controller.ConsolidatorController;
import com.vdf.sisconsolid.persistencemodule.dto.ConsolidatorDTO;

@Path("consolidators")
public class RestConsolidator {

	@Context HttpServletRequest request;
	
	@GET
	@Produces("application/json")
	public Map<String, Object> get(@QueryParam("filter") String filters) {
		return ConsolidatorController.processGet(filters);
	}

	@GET
	@Path("{id}")
	@Produces("application/json")
	public Map<String, Object> getById(@PathParam("id") Long id) {
		return ConsolidatorController.processGetById(id);
	}

	@POST
	@Produces("application/json")
	public Map<String, Object> post(ConsolidatorDTO consolidator) {
		return ConsolidatorController.processPostOrPut(consolidator);
	}

	@PUT
	@Path("{id}")
	@Produces("application/json")
	public Map<String, Object> put(@PathParam("id") Long id, ConsolidatorDTO consolidator) {
		return ConsolidatorController.processPostOrPut(consolidator);
	}

	@DELETE
	@Path("{id}")
	@Produces("application/json")
	public Map<String, Object> delete(@PathParam("id") Long id) {
		return ConsolidatorController.processCancel(id);
	}
	
	@GET
	@Path("list")
	@Produces("application/json")
	public Map<String, Object> getConsolidators() {
		return ConsolidatorController.processGetConsolidators(request);
	}
	
}
